package stage1.module3.Q1;

import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        int[] test = {1, 3, 2, 5};
//         int[] test = {};
//         int[] test = null;
        System.out.println("Arrays.toString 的结果: ");
        System.out.println(Arrays.toString(test));
        System.out.println("我的结果: ");
        System.out.println(toString(test));
    }

    public static String toString(int[]  arr) {
        // 分隔符
        final String SEP = ", ";

        if (arr == null) {
            return "null";
        }

        String out = "[";
        int len = arr.length;
        for (int i = 0; i < len; i++) {
            out += arr[i];
            if (i != len -1) {
                out += SEP;
            }
        }
        out += "]";
        return out;
    }
}
